﻿using mediaPrime.Controls;
using mediaPrime.Sdk;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace mediaPrime.Plugin.SystemManagement.Dialogs
{
    /// <summary>
    /// Interaktionslogik für ChangeSettingsViewDialog.xaml
    /// </summary>
    public partial class ChangeSettingsViewDialog : MPDialog
    {
        public SettingScope View { get; private set; }

        public ChangeSettingsViewDialog(string currentValue)
        {
            InitializeComponent();

            var menuList = new List<MPMenuItemBase>();
            menuList.Add(new MPMenuItem("Standard") { Tag = "Standard" });
            menuList.Add(new MPMenuItem("Advanced") { Tag = "Advanced" });
            menuList.Add(new MPMenuItemSeparator());
            menuList.Add(new MPMenuItem("Cancel") { Tag = "Cancel" });

            menuControl.ItemsSource = menuList;

            if (currentValue == "Advanced")
                menuControl.SelectedIndex = 1;
            else
                menuControl.SelectedIndex = 0;
        }

        private void menuControl_MenuItemClicked(object sender, MPMenuItemClickedEventArgs e)
        {
            if (e.Item is MPMenuItem)
            {
                var item = e.Item as MPMenuItem;
                var tag = item.Tag as string;
                if (tag == "Cancel")
                    DialogResult = false;
                else if (tag == "Standard")
                {
                    View = SettingScope.Standard;
                    DialogResult = true;
                }
                else if (tag == "Advanced")
                {
                    View = SettingScope.Advanced;
                    DialogResult = true;
                }
            }
        }
    }

}
